import java.util.HashMap;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-11-10
 * Time: 21:07
 */
public class Main {

    /**
     * 一维前缀和
     *
     * @param args
     */
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        int[] arr = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            arr[i] = in.nextInt();
        }
        long[] dp = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            dp[i] = dp[i - 1] + arr[i];
        }
        while (q > 0) {
            int l = in.nextInt();
            int r = in.nextInt();
            System.out.println(dp[r] - dp[l - 1]);
            q--;
        }
    }

    /**
     * 二维前缀和
     */
    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int q = in.nextInt();
        int[][] arr = new int[n + 1][m + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                arr[i][j] = in.nextInt();
            }
        }
        long[][] dp = new long[n + 1][m + 1];
        //前缀和矩阵
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1] + arr[i][j] - dp[i - 1][j - 1];
            }
        }
        //查询
        while (q > 0) {
            int x1 = in.nextInt();
            int y1 = in.nextInt();
            int x2 = in.nextInt();
            int y2 = in.nextInt();
            System.out.println(dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1]);
            q--;
        }
    }

    /**
     * 寻找数组的中心下标
     *
     * @param nums
     * @return
     */
    public int pivotIndex(int[] nums) {
        int n = nums.length;
        int[] f = new int[n];// 前缀和数组
        int[] g = new int[n];// 后缀和数组
        // 数组预处理
        f[0] = 0;
        g[n - 1] = 0;
        //往前缀和数组前数据
        for (int i = 1; i < n; i++) {
            f[i] = f[i - 1] + nums[i - 1];
        }
        //往后缀和数组前数据
        for (int i = n - 2; i >= 0; i--) {
            g[i] = g[i + 1] + nums[i + 1];
        }
        //使用前缀和数组、后缀和数组
        for (int i = 0; i < n; i++) {
            if (f[i] == g[i]) {
                return i;
            }
        }
        return -1;
    }

    /**
     * 除自身以外数组的乘积
     */
    public int[] productExceptSelf(int[] nums) {
        int n = nums.length;
        int[] ret = new int[n];
        int[] f = new int[n];//前缀积数组
        int[] g = new int[n];//后缀积数组
        // f[i] = f[i-1]*nums[i-1]
        // g[i] = g[i+1]*nums[i+1]
        f[0] = 1;
        g[n - 1] = 1;
        for (int i = 1; i < n; i++) {
            f[i] = f[i - 1] * nums[i - 1];
        }
        for (int i = n - 2; i >= 0; i--) {
            g[i] = g[i + 1] * nums[i + 1];
        }

        //填数组
        for (int i = 0; i < n; i++) {
            ret[i] = f[i] * g[i];
        }
        return ret;
    }

    /**
     * 和为k的子数组
     *
     * @param nums
     * @param k
     * @return
     */
    public int subarraySum(int[] nums, int k) {
        HashMap<Integer, Integer> hash = new HashMap<>();
        hash.put(0, 1);
        int dp = 0;
        int ret = 0;
        for (int i = 0; i < nums.length; i++) {
            dp += nums[i];// 计算当前位置的前缀和
            ret += hash.getOrDefault(dp - k, 0);// 统计结果的个数
            hash.put(dp, hash.getOrDefault(dp, 0) + 1);
        }
        return ret;
    }

    public int subarraysDivByK(int[] nums, int k) {
        HashMap<Integer, Integer> hash = new HashMap<>();// 前缀和的余数,次数
        hash.put(0 % k, 1);
        int dp = 0;
        int ret = 0;
        for (int i = 0; i < nums.length; i++) {
            dp += nums[i];//计算当前位置的前缀和
            ret += hash.getOrDefault((dp % k + k) % k, 0);//统计结果
            //把余数丢进哈希表中
            hash.put((dp % k + k) % k, hash.getOrDefault((dp % k + k) % k, 0) + 1);
        }
        return ret;
    }

    public int findMaxLength(int[] nums) {
        HashMap<Integer, Integer> hash = new HashMap<>();// 前缀和
        hash.put(0, -1);
        int dp = 0, len = 0;
        for (int i = 0; i < nums.length; i++) {
            dp += (nums[i] == 0 ? -1 : 1);// 计算位置当前前缀和
            if (hash.containsKey(dp)) {
                len = Math.max(len, i - hash.get(dp));
            } else {
                //如果不存在则加入哈希表
                hash.put(dp, i);
            }
        }
        return len;
    }

    public int[][] matrixBlockSum(int[][] mat, int k) {
        int m = mat.length;
        int n = mat[0].length;
        // 前缀和矩阵
        int[][] dp = new int[m + 1][n + 1];
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + mat[i - 1][j - 1];
            }
        }

        // 使用矩阵
        int[][] ret = new int[m][n];
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                int x1 = Math.max(0, i - k) + 1;
                int y1 = Math.max(0, j - k) + 1;
                int x2 = Math.min(m - 1, i + k) + 1;
                int y2 = Math.min(n - 1, j + k) + 1;
                ret[i][j] = dp[x2][y2] - dp[x1 - 1][y2] - dp[x2][y1 - 1] + dp[x1 - 1][y1 - 1];
            }
        }
        return ret;
    }


}
